<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background: red;
        }
    </style>
</head>
<body>
    <div id="div" >
    </div>
    <script>
        // element.style.attr 有局限性:只能获取内联样式
        let div=document.getElementById("div");
        
        let value=getComputedStyle(div,null).width;
        console.log(value);
    </script>
</body>
</html>